import type {Ref} from 'vue';
import {onMounted,onActivated} from 'vue';

export default function(
	autofocus:() => boolean,
	eleRef:Ref<HTMLElement>,
	focusState:Ref<boolean>,
):void{
	function autofocusFn(){
		if(autofocus()&&!focusState.value){
			eleRef.value.focus();
		}
	}
	onMounted(autofocusFn);
	onActivated(autofocusFn);
}